<?php 
	session_start();
	include("php/conexion.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
	<head>
		<meta name="description" content="Torneo Comercial de Basket">
		<meta name="keywords" content="torneo.basket,comercial,amateur,vector,it,vector-it,cordoba,argentina">
		<meta name="author" content="Vector-IT">
	    <title>Torneo TCB</title>
	    <link rel="shortcut icon" href="imagenes/favicon.ico" type="image/x-icon" />
	    <link rel="icon" href="imagenes/favicon.ico" type="image/x-icon" />
		<link rel="image_src" href="http://www.torneotcb.com.ar/imagenes/logo.png" />
		<link rel="stylesheet" type="text/css" href="css/tcb.css">
		
        <meta property="og:title" content="Torneo TCB" />
		<meta property="og:url" content="http://www.torneotcb.com.ar" />
		<meta property="og:description" content="Torneo Comercial de Basket" />
		<meta property="og:image" content="http://www.torneotcb.com.ar/imagenes/logo.png" />
		
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		
		<link rel="stylesheet" type="text/css" href="jquery/css/custom-theme/jquery-ui-1.10.3.custom.min.css" />
	    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
		<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>		
		<script src="js/publicos.js"></script>
		
	    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		
		<!-- Google Hosted jQuery Core -->
		<script src="js/jquery.ez-bg-resize.js" type="text/javascript" charset="utf-8"></script>
		<script>
			$(document).ready(function() {
				
				var BGImageArray = ["bg.jpg","bg2.jpg","bg5.jpg","bg6.jpg","bg7.jpg","bg8.jpg"];
				var BGImage = BGImageArray[Math.floor(Math.random()*BGImageArray.length)];
	
				$("body").ezBgResize({
					img     : "imagenes/fondos/" + BGImage, // Relative path example.  You could also use an absolute url (http://...).
					opacity : 1, // Opacity. 1 = 100%.  This is optional.
					center  : true // Boolean (true or false). This is optional. Default is true.
				});
			});
		</script>
		<script>
			<?php
				if (isset($_GET["NumePart"])) {
					$con = new mysqli($dbhost, $dbuser, $dbpass, $db) or die("Problemas al conectar al Servidor");
					$query = "SELECT NumeEsta from partidos WHERE NumePart = " . $_GET["NumePart"];
					$tabla = $con->query($query) or die("Problemas al realizar consulta");
				
					$fila = $tabla->fetch_array();
					$tabla->free();
					$con->close();
					
					if ($fila["NumeEsta"] == "1") {
						$strSalida = 'var intI = 21;';
						
						$strSalida.= $crlf.'var tiempo1 = setInterval(function(){';
						$strSalida.= $crlf.'				if (document.getElementById("hdnNumeEsta").value == 1) {'; 
						$strSalida.= $crlf.'					intI = 21;';						
						$strSalida.= $crlf.'					cargarDatos();';
						$strSalida.= $crlf.'				}';
						$strSalida.= $crlf.'				else';
						$strSalida.= $crlf.'					clearInterval(tiempo1);';
						$strSalida.= $crlf.'			},21000);';

						$strSalida.= $crlf.' var tiempo2 = setInterval(function(){';
						$strSalida.= $crlf.'				if (document.getElementById("hdnNumeEsta").value == 1) {';
						$strSalida.= $crlf.'					intI--;';
						$strSalida.= $crlf.'					document.getElementById("divTimer").innerHTML = "Actualizando en " + intI.toString() + " segundos.";';
						$strSalida.= $crlf.'				}';
						$strSalida.= $crlf.'				else {';
						$strSalida.= $crlf.'					clearInterval(tiempo2);';
						$strSalida.= $crlf.'					document.getElementById("divTimer").innerHTML = "";';
						$strSalida.= $crlf.'				}';
						$strSalida.= $crlf.'			},1000);';
							
						echo $strSalida;
					}
				} 
			?>
		</script>
		<script type="text/javascript">
			function armarPagina() {
				cargarEncabezado(function(){
					cargarDatos();
				});
			}
	
			function cargarEncabezado(callback) {
	            if (window.XMLHttpRequest)
	            {// code for IE7+, Firefox, Chrome, Opera, Safari
	                xmlhttp=new XMLHttpRequest();
	            }
	            else
	            {// code for IE6, IE5
	                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	            }
	
	            xmlhttp.onreadystatechange=function()
	            {
	                if (xmlhttp.readyState==4 && xmlhttp.status==200) {
	                	document.getElementById("divEncabezado").innerHTML = xmlhttp.responseText;
	                	callback();
	                }
	            };
	            xmlhttp.open("POST","encabezado.php",true);
	            xmlhttp.send();
			}
		
			function cargarDatos() {
				var NumePart = getVariable("NumePart");

	            if (window.XMLHttpRequest)
	            {// code for IE7+, Firefox, Chrome, Opera, Safari
	                xmlhttp=new XMLHttpRequest();
	            }
	            else
	            {// code for IE6, IE5
	                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	            }
	
	            xmlhttp.onreadystatechange = function()
	            {
	                if (xmlhttp.readyState==4 && xmlhttp.status==200) {
	                    document.getElementById("contenido").innerHTML = xmlhttp.responseText;
	                }
	            };
	            xmlhttp.open("POST","php/partido.php",true);
	            xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	            xmlhttp.send("NumePart=" + NumePart);
			}
		</script>
	</head>
	<body onload="armarPagina();">
		<!-- Codigo para analytics -->
		<?php include_once("php/analyticstracking.php") ?>
		
		<!-- Codigo para facebook -->
		<div id="fb-root"></div>
		<script>
		  window.fbAsyncInit = function() {
			    // init the FB JS SDK
			    FB.init({
			      appId      : '<?php echo $fb_appId;?>',                        // App ID from the app dashboard
			      channelUrl : '//www.torneotcb.com.ar/php/channel.php', // Channel file for x-domain comms
			      status     : true,                                 // Check Facebook Login status
			      cookie	 : true,
			      xfbml      : true                                  // Look for social plugins on the page
			    });

			    // Additional initialization code such as adding Event Listeners goes here
			  };

			// Load the SDK asynchronously
			(function(d, s, id) {
			  var js, fjs = d.getElementsByTagName(s)[0];
			  if (d.getElementById(id)) return;
			  js = d.createElement(s); js.id = id;
			  js.src = "//connect.facebook.net/es_LA/all.js";
			  fjs.parentNode.insertBefore(js, fjs);
			}(document, 'script', 'facebook-jssdk'));
		</script>
		
<!-- Ventanas modales -->
		<div id="divFondo" class="fondo" onclick="cerrarLogin();"></div>
		
		<div id="divLogin" class="modal">
			<table style="width: 100%;" class="accesos">
				<tr>
					<td>
						Acceder al sistema
					</td>
					<td style="text-align: right;">
					<input type="button" value="X" onclick="cerrarLogin();" class="boton" />
					</td>
				</tr>
			</table>
			<div style="padding-top: 10px;">
				<form name="frmLogin" id="frmLogin" method="POST" onSubmit="return false;">
					<table>
						<tr>
							<td>
								<label for="txtUser">Usuario: </label>
							</td>
							<td>
								<input type="text" id="txtUser" required />
							</td>
						</tr>
						<tr>
							<td>
								<label for="txtPass">Contrase&ntilde;a: </label>
							</td>
							<td>
								<input type="password" id="txtPass" required />
							</td>
						</tr>
						<tr>
							<td colspan="2" style="text-align: right;">
								<div id="divLoginError" class="error"></div>
								<input type="submit" value="Aceptar" onclick="login(location.href);" class="boton"/>&nbsp;
								<input type="button" value="Cancelar" onclick="cerrarLogin();" class="boton" />
							</td>
						</tr>
					</table>
				</form>
			</div>
		</div>
				
		<div class="contenedor">
		    <div class="encabezado" id="divEncabezado">
		    	<img src="imagenes/logo_viejo.png" />
			</div>
		
	    	<input type="button" value="Volver" class="boton" onclick="history.go(-1);" />
	    	<div id="divTimer"></div>
	    	
	    	<div id="contenido" class="contenido">
	    		<div id="actualizando"><img src="imagenes/spinner.gif" style="width: 16px; height: 16px;" />Actualizando...</div>
		    </div>
		    <div class="fb-comments" data-href="http://www.torneotcb.com.ar/verPartido.php?NumePart=<?php echo $_GET["NumePart"];?>" data-colorscheme="dark" data-numposts="10" data-width="500"></div>
	
		    <div id="pie" class="pie">
            	<div style="float: left;">
            		Estamos en Redes Sociales
            	  	<a href="http://www.facebook.com/pages/Torneo-Comercial-De-Basquet/126750014062523" target="_blank"><img src="imagenes/facelogo.png" height="25" width="25"  /></a>
            	  	<a href="http://twitter.com/TorneoComercial" target="_blank"><img src="imagenes/twitlogo.png" height="25" width="25" /></a>
            	</div>
                <div style="float: right;">
                	<p>
                		2013 Copyright Torneo TCB.<br/>
                		Todos los derechos reservados.<br/>
                    	Powered by <a href="http://www.vector-it.com.ar" target="_blank"><img src="imagenes/vectorit.png" height="15" width="15" />Vector-IT</a>
                    </p>
				</div>
		    </div>
		    	    
		</div>
	</body>
</html>